const pool = require("../connection/sqlPool");

async function GETCOLLECT(username) {
    try{
        const promisePool = pool.promise();
        const [rows, fields] = await promisePool.query("SELECT * FROM Food_collect WHERE user_name = ?", [username]);
        return rows;
    }catch(err){
        return err.message
    }

}

async function ADDCOLLECT(username, foodname) {
    try{
        const promisePool = pool.promise();
        const [rows, fields] = await promisePool.query("INSERT INTO Food_collect (user_name, food) VALUES (?, ?)", [username, foodname]);
        return {status:"249",msg:"已成功添加数据"}
    }catch(err){
        return err.message
    }
    
}

module.exports = {
    GETCOLLECT,ADDCOLLECT
}

